'''
Reschedule test
'''

from interactive import *

#1)

css("#ColonyView")
linkpart("EPO").click()
twait()

css("#ColonyMenu")
linkpart("Reschedule").click()
twait()
alert = driver.switch_to_alert()
assert(alert.text == "Successfully rescheduled.")
alert.accept()

linkpart("Experiments").click()
twait()

linkpart("Alpha").click()
twait()

linkpart("Alpha 1").click()
twait()

driver.find_elements_by_css_selector("#InterventionList li")[0].click()
twait()

Edit()

css("#InterventionDetail #StartDate").clear()
css("#InterventionDetail #StartDate").send_keys("2012-01-01")
css("#InterventionDetail #EndDate").clear()
css("#InterventionDetail #EndDate").send_keys("2012-02-01")
Select(css("#InterventionDetail #Active")).select_by_value("2")
css("#InterventionDetail #Comment").clear()
css("#InterventionDetail #Comment").send_keys("comment text")

Done()

driver.find_elements_by_css_selector("#InterventionList li")[0].click()
twait()

assert(css("#InterventionDetail #StartDate").get_attribute("value") == "2012-01-01")
assert(css("#InterventionDetail #EndDate").get_attribute("value") == "2012-02-01")
assert(Select(css("#InterventionDetail #Active")).first_selected_option.text == "Done")
assert(css("#InterventionDetail #Comment").get_attribute("value") == "comment text")

driver.quit()
